1. Field of the Invention
The present invention relates to a computer, and in particular, to techniques for rewriting the contents of a nonvolatile erasable memory, which stores computer programs, when a user operates a computer.
2. Description of the Related Art
A conventional computer, which is built into equipment such as an automobile and controls the operation of the equipment, has a structure as shown in FIG. 4.
When a computer operates in the writer-rewriting mode in which a writer device (not shown in the figures) placed in a factory rewrites the contents of a nonvolatile memory 6, a CPU (Central Processing Unit) 2 starts the execution of instructions contained in programs that are stored in a boot memory 7.
On the other hand, when the computer operates in the user mode in which a user operates the computer, the CPU 2 starts the execution of instructions contained in programs that are stored in a user area A61 of the nonvolatile memory 6 in accordance with a directive sent from a start address selection circuit 8.
Additionally, when the computer operates in the self-mode in which the contents of the nonvolatile memory 6 are rewritten (re-programmed) during which a user operates the computer, instructions that are necessary for the rewriting operation in addition to a boot program are transferred to a RAM (Random Access Memory) 5 from the nonvolatile memory 6 or from the outside of the computer. Subsequently, the CPU 2 reads out the boot program and the instructions from the RAM 5, and then the CPU 2 executes these to rewrite the contents of the nonvolatile memory 6.
According to the above-described technique, however, it may become impossible for the computer to continue to operate normally if a short break in the supply of power occurs during the erasure operation of the user area A61 of the nonvolatile memory 6 where programs including the boot program are stored. Hereafter, the term xe2x80x9cboot programxe2x80x9d may be used as the representative of these programs including the boot program for convenience.
Furthermore, even if the erasure operation is successfully completed, if a short break in the supply of power occurs while a new boot program is written into the nonvolatile memory 6, the writing operation may be carried out incompletely.
In the above cases, even if a reset operation of the system were attempted to restart the system, it would be impossible to successfully restart the system because the new boot program was incompletely rewritten. In this way, the conventional computer as stated above has a problem in that the user area A61 where a boot program may be stored cannot be safely erased in the self-mode.
In order to solve this problem, techniques for safely rewriting the contents of a user area where a boot program is stored are disclosed in Japanese Unexamined Patent Application, First Publication, Nos. Hei 8-255084 and Hei 10-149282.
Both publications employ a technique wherein when rewriting the boot program stored in a boot area, which corresponds to the user area A61 shown in FIG. 4, the old boot program (i.e. the boot program currently used) is copied to an empty user area in order to back up this old boot program, and then the contents of the boot area are erased, after that a new boot program is written into the boot area, and then the old boot program that was copied to the empty user area is erased provided that the writing operation of the new boot program has been successfully completed.
According to this technique, even if the new boot program were incompletely written because of a short break in the supply of power, the old boot program makes it possible to restart the system, thus a situation in which the restoration of the system becomes impossible can be avoided.
The above-described technique, however, causes a problem in that it is required to perform many actions such as a copying operation of the old boot program to the empty user area, and an erasure operation of the old boot program once it is no longer necessary because of the completion of the writing operation of the new boot program. Therefore, the handling is complicated and substantial time is required to carry out the rewriting operation.
It is therefore an object of the present invention to provide a computer that is capable of safely rewriting boot programs stored in a nonvolatile memory with fewer actions in the self-mode (i.e. a mode for re-programming the contents of the nonvolatile memory with the nonvolatile memory being mounted onto a printed circuit board when a user operates the computer) by providing flags for every user area for specifying the boot area.
A computer according to the present invention is provided with: a nonvolatile memory which is divided into a plurality of divided areas, each divided area being separately erasable and including a user area and a boot area designation flag indicating whether the corresponding user area is specified as a boot area; an area designation flag register which specifies the user area including a boot program among a plurality of user areas; and a processor which sets the value of the area designation flag register based on the values of a plurality of boot area designation flags, wherein the user area which stores the program for starting the operation of the processor is determined based on the value of the area designation flag register.
Since the present invention is provided with boot area designation flags and an area designation flag register, it is possible to switch the user area that contains a boot program for starting a system, and the rewriting of a boot program stored in the nonvolatile memory can always be carried out with the presence of the old boot program that is currently used. For this reason, even if a rewriting operation has not been completed normally due to a short break in the supply of power while the rewriting operation is carried out in the self-mode, it possible to restore the system by performing the rewriting operation once again. Accordingly, the rewriting operation can be performed with fewer actions in a short period.